package com.jic.interaction.ChinaPost.controller;

import com.jic.common.base.vo.RestResult;
import com.jic.interaction.ChinaPost.model.entity.UserInfo;
import com.jic.interaction.ChinaPost.model.vo.request.UserInfoRequest;
import com.jic.interaction.ChinaPost.model.vo.response.UserInfoResponse;
import com.jic.interaction.ChinaPost.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

/**
 * @ClassName UserInfoController
 * @Description TODO 用户信息
 * @Author 陈鸿锋
 * @Date 2020/11/5 14:29
 * @Version 1.0
 **/
@Api(value="用户信息", tags = "用户信息", description = "UserInfoController")
@RestController
@RequestMapping("/user")
public class UserInfoController {
    @Autowired
    UserInfoService userInfoService;

    /*
     * @Author chengpunan
     *@Package com.jic.interaction.controller
     *ClassName UserInfoController
     * @Description  //TODO
     * @Date 11:52 2020/11/10
     * @Param UserInfoRequest
     * @return UserInfoResponse
     * @Version:1.0
     **/
    @ApiOperation(value = "用户信息查询接口", notes = "用户信息查询接口")
    @PostMapping("/queryAccountInfo")
    public RestResult<UserInfoResponse> getQueryAccountInfo(@Valid @RequestBody UserInfoRequest request) throws InterruptedException, ExecutionException, IOException {
        UserInfo param=new UserInfo();
        BeanUtils.copyProperties(request,param);
        UserInfo userInfo = userInfoService.getUserInfo(param);
        if(userInfo==null){
            return RestResult.error("14190004","用户不存在");
        }
        UserInfoResponse userInfoResponse=new UserInfoResponse();
        BeanUtils.copyProperties(userInfo,userInfoResponse);
        return RestResult.success(userInfoResponse);
    }



}
